package com.javaEEpro.testclass;

import java.util.Objects;

public class test {
    public static void main(String[] args) {
        siliver s=new siliver();
        s.setName("凌毅");
        s.setMoney(5000);
        gold g=new gold();
        g.setName("谢玉婷");
        g.setMoney(10000);
        s.pay(100);
        g.pay(100);
        String name="1";
        String name1=null;
        String age="1";
        System.out.println(Objects.isNull(age));


    }
}

abstract class card{
    private String name;

    private double money;

    public abstract void pay(double pay_money);

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        card card = (card) o;
        return Double.compare(card.money, money) == 0 &&
                Objects.equals(name, card.name);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }
}

class siliver extends card{



    @Override
    public void pay(double pay_money) {
        //在子类里面不能直接调用父类的私有变量，要通过get方法获得和写入，子类变量调用set和get方法不需要加上类名
        System.out.println(getName()+"先生/女士你好");
        System.out.println("你本次的消费是："+pay_money);
        System.out.println("你的余额是："+getMoney());
        double r=getMoney()-pay_money*0.85;
        //更新余额
        setMoney(r);
        System.out.println("剩余余额："+r);
        System.out.println(this+"我在这里");
    }
}

class gold extends card{


    @Override
    public void pay(double pay_money) {
        System.out.println(getName()+"先生/女士你好");
        System.out.println("你本次的消费是："+pay_money);
        System.out.println("你的余额是："+getMoney());
        double r=getMoney()-pay_money*0.8;
        setMoney(r);
        System.out.println("剩余余额："+r);
    }
}